﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace cse480_rtl
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        private MainDataSet _DataSet;
        public MainDataSet DataSet
        {
            get { return _DataSet; }        
        }

        private bool dataLoaded = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!dataLoaded)
            {
                _DataSet = new MainDataSet();
                string sqlSelect = string.Empty;

                foreach (DataTable tbl in _DataSet.Tables)
                    sqlSelect += "SELECT * FROM " + tbl.TableName +";";

                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString = "Data Source= 35.9.22.104; Initial Catalog=cse480-rtl ;User ID=sa;password= mcppsitb$$";
                    try
                    {
                        connection.Open();
                        SqlDataAdapter adapter = new SqlDataAdapter(sqlSelect, connection);
                        adapter.Fill(_DataSet);
                        connection.Close();
                        dataLoaded = true;
                    }
                    catch
                    {
                    }
                }
            }

        }
    }
}
